<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>[%$softtitle%]</title>
<link href="templates/css/baselist.css" rel="stylesheet" type="text/css" />
<link href="templates/css/all.css" rel="stylesheet" type="text/css" />
<link href="templates/css/clickmenu.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/control.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<script type="text/javascript" src="js/pagebotton.js"></script>
<script type="text/javascript" src="js/hotelsearch.js"></script>
<script type="text/javascript">
	var shoubound = false;  //是否显示之前的日期，true显示，false不显
	var resizewindow= null;

	window.onresize = function(){
		var h = $(window).height();
		if(resizewindow!=h){
			sizewindow();
			resizewindow=h;
		}
	}

	function sizewindow(){
		var h = $(window).height();
		if(document.getElementById("mainbodyauto")){
			$('.manageadd').css({height:h-40});
			$('.manageedit').css({height:h-40});
		}
	}
	
	var iframename = "[%$iframename%]";
	
	$(document).ready(function(){
		
		var h = '[%$iframeheightwindow%]';
		var _SCP_BORDER_HEIGHT = 4;
		$('.manageadd').css({height:h-40});
		
		$("#mainnextbody").hide();
		$("#searchmanger").show();
		
		//自动完成城市功能
		function autocityname() {
			var s = '<dl><dt>中文/拼音或↑↓选择</dt>';
			var cityname = $("#cityname").val();
			for(var i=0;i<cityNameList.length;i++) {
				var patt1 = new RegExp("^"+cityname,"i");
				if(patt1.test(cityNameList[i].Name) || patt1.test(cityNameList[i].Spell) || patt1.test(cityNameList[i].Spell.replace(/ /g, '')) || patt1.test(cityNameList[i].Alias) || patt1.test(cityNameList[i].Alias.replace(/ /g, '')) || patt1.test(cityNameList[i].Abbr)) {
					s += '<dd><a href="#body" name="'+cityNameList[i].Id+'_'+cityNameList[i].Name+'" onclick="setCityValue(\''+cityNameList[i].Id+'\',\''+cityNameList[i].Name+'\');" hidefocus="true">'+cityNameList[i].Name+'('+cityNameList[i].Abbr+')</a></dd>';
				}
			}
			s += '</dl>';
			$("#autoCompleteCityName").html('');
			$("#autoCompleteCityName").html(s);
			var offset = $("#cityname").offset();
			$(".cityname").css({"left":offset.left,"top":offset.top+$("#cityname").height()+_SCP_BORDER_HEIGHT});
			$(".cityname").show();
		}
		//默认城市（自动完成）
		var currcityname = new Array("0101","2301","2001","1201","1101","1601","2201","0201","2003","1102","0301","2701","1401","0401","2503");
		function divcityname() {
			var s = '<dl><dt>中文/拼音或↑↓选择</dt>';
			for(var i=0;i<cityNameList.length;i++) {
				for(var n=0;n<currcityname.length;n++) {
					if(cityNameList[i].Id==currcityname[n]) {
						s += '<dd><a href="#body" name="'+cityNameList[i].Id+'_'+cityNameList[i].Name+'" onclick="setCityValue(\''+cityNameList[i].Id+'\',\''+cityNameList[i].Name+'\');" hidefocus="true">'+cityNameList[i].Name+'('+cityNameList[i].Abbr+')</a></dd>';
					}
				}
			}
			s += '</dl>';
			$("#autoCompleteCityName").html('');
			$("#autoCompleteCityName").html(s);
			var offset = $("#cityname").offset();
			$(".cityname").css({"left":offset.left,"top":offset.top+$("#cityname").height()+_SCP_BORDER_HEIGHT});
			$(".cityname").show();
		}
		//自动完成附近标志性坐标功能
		function getnearby() {
			var citycode = $("#cityname").val();
			var searchname = $("#hotelnearby").val();
			$.get("index.php",{archive:"hotelmain",action:"searchnearby",citycode:encodeURIComponent(citycode),searchname:encodeURIComponent(searchname),ran:Math.random()},
			function(data){
			  var data = eval("("+data+")");
			  var s = '<dl><dt>选择下面地标↑↓选择</dt>';
			  for(var i=0;i<data.length;i++) {
				  s += '<dd><a href="#body" name="'+data[i].Lng+','+data[i].Lat+'_'+data[i].Name+'" onclick="setNearValue(\''+data[i].Lng+','+data[i].Lat+'\',\''+data[i].Name+'\');" hidefocus="true">'+data[i].Name+'</a></dd>';
			  }
			  s += '</dl>';
			  $("#autoCompleteNearby").html('');
			  $("#autoCompleteNearby").html(s);
			  var offset = $("#hotelnearby").offset();
			  $(".hotelnearby").css({"left":offset.left,"top":offset.top+$("#hotelnearby").height()+_SCP_BORDER_HEIGHT});
			  $(".hotelnearby").show();
			}); 
		}
		//--------------------------------------
		//绑定城市自动完成事件
		$("#cityname").keyup(function(event) {
			var cityname = $("#cityname").val();
			if(cityname) {
				if (event.keyCode != 13 && event.keyCode != 9 && event.keyCode != 20 && event.keyCode != 16 && event.keyCode != 17) {
					autocityname();
				}
			} else {
				divcityname();	
			}
		});
		$("#cityname").focus(function() {
			if($("#cityname").val() != '') {
				autocityname();
			} else {
				divcityname();
			}
		});
		//-----------------------------------------------
		//绑定键盘上下键控制自动完成
		var currentLine=-1;
		var ncurrentLine=-1;
		$(document).keydown(function(event){
			e = event ? event : (window.event ? window.event : null); 
			var isshow = $(".cityname").css('display');
			var isnearby = $(".hotelnearby").css('display');
			if(isshow == "block") {
				switch(e.keyCode)    
				{
					case 38: //上方向键
						currentLine--;
						changeItem(e.keyCode,'city'); 
						break; 
					case 40: //下方向键
						currentLine++; 
						changeItem(e.keyCode,'city'); 
						break; 
					default: 
						break;
				}
			}
			if(isnearby == "block") {
				switch(e.keyCode)    
				{
					case 38: //上方向键
						ncurrentLine--;
						changeItem(e.keyCode,'nearby'); 
						break; 
					case 40: //下方向键
						ncurrentLine++; 
						changeItem(e.keyCode,'nearby'); 
						break; 
					default: 
						break;
				}
			}
			$("#autoCompleteCityName dd > a").mouseover(function(){
				$("#autoCompleteCityName dd > a").removeClass("active");
			});
			$("#autoCompleteNearby dd > a").mouseover(function(){
				$("#autoCompleteNearby dd > a").removeClass("active");
			});
			function changeItem(code,type)
			{
				if(type == "city") {
					$("#autoCompleteCityName dd > a").removeClass("active");
					var len = $("#autoCompleteCityName dd").length;
					if(code == 38) {
						if(currentLine == -1) {
							$("#cityname").focus();
						} else if(currentLine < -1) {
							currentLine=len;
							var cityvalue = $("#autoCompleteCityName a").get(currentLine).name.split('_');
							$("#cityname").val(cityvalue[1]);
							$("#cityid").val(cityvalue[0]);
							$("#autoCompleteCityName a").get(currentLine).className="active";
							$("#autoCompleteCityName a").get(currentLine).focus();
						} else {
							var cityvalue = $("#autoCompleteCityName a").get(currentLine).name.split('_');
							$("#cityname").val(cityvalue[1]);
							$("#cityid").val(cityvalue[0]);
							$("#autoCompleteCityName a").get(currentLine).className="active";
							$("#autoCompleteCityName a").get(currentLine).focus();
						}
					}
					if(code == 40) {
						if(currentLine<-1) currentLine=len;
						if(currentLine >= len) {
							currentLine = -1;
							$("#cityname").focus();
						} else {
							var cityvalue = $("#autoCompleteCityName a").get(currentLine).name.split('_');
							$("#cityname").val(cityvalue[1]);
							$("#cityid").val(cityvalue[0]);
							$("#autoCompleteCityName a").get(currentLine).className="active";
							$("#autoCompleteCityName a").get(currentLine).focus();
						}
					}
				} else if(type == "nearby") {
					$("#autoCompleteNearby dd > a").removeClass("active");
					var len = $("#autoCompleteNearby dd").length;
					if(code == 38) {
						if(ncurrentLine == -1) {
							$("#hotelnearby").focus();
						} else if(ncurrentLine < -1) {
							ncurrentLine=len;
							var nearvalue = $("#autoCompleteNearby a").get(ncurrentLine).name.split('_');
							$("#hotelnearby").val(nearvalue[1]);
							$("#coordinate").val(nearvalue[0]);
							$("#autoCompleteNearby a").get(ncurrentLine).className="active";
							$("#autoCompleteNearby a").get(ncurrentLine).focus();
						} else {
							var nearvalue = $("#autoCompleteNearby a").get(ncurrentLine).name.split('_');
							$("#hotelnearby").val(nearvalue[1]);
							$("#coordinate").val(nearvalue[0]);
							$("#autoCompleteNearby a").get(ncurrentLine).className="active";
							$("#autoCompleteNearby a").get(ncurrentLine).focus();
						}
					}
					if(code == 40) {
						if(ncurrentLine<-1) ncurrentLine=len;
						if(ncurrentLine >= len) {
							ncurrentLine = -1;
							$("#hotelnearby").focus();
						} else {
							var nearvalue = $("#autoCompleteNearby a").get(ncurrentLine).name.split('_');
							$("#hotelnearby").val(nearvalue[1]);
							$("#coordinate").val(nearvalue[0]);
							$("#autoCompleteNearby a").get(ncurrentLine).className="active";
							$("#autoCompleteNearby a").get(ncurrentLine).focus();
						}
					}
				}
			 }
		});
		//--------------------------------------------------------------
		//根据鼠标坐标关闭自动完成提示框
		$(document).click(function(e){
			e= e || window.event; 
			var mousePos = mouseCoords(e); 
			var offset = $("#cityname").offset();
			var noffset = $("#hotelnearby").offset();
			var isshow = $(".cityname").css('display');
			var isnearby = $(".hotelnearby").css('display');
			if(isshow == "block") {
				if(mousePos.x < offset.left || mousePos.x > (offset.left+$("#cityname").width()) || mousePos.y < offset.top || mousePos.y > (offset.top + $("#cityname").height() + $("#autoCompleteCityName").height())) {
					$("#autoCompleteCityName").hide();
				}
			}
			if(isnearby == 'block') {
				if(mousePos.x < noffset.left || mousePos.x > (noffset.left+$("#hotelnearby").width()) || mousePos.y < noffset.top || mousePos.y > (noffset.top + $("#hotelnearby").height() + $("#autoCompleteNearby").height())) {
					$("#autoCompleteNearby").hide();
				}	
			}
		});
		//获取鼠标坐标
		function mouseCoords(ev) 
		{ 
			if(ev.pageX || ev.pageY){ 
				return {x:ev.pageX, y:ev.pageY}; 
			} 
			return { 
				x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 
				y:ev.clientY + document.body.scrollTop - document.body.clientTop 
			}; 
		}
		
		//附近标志性坐标
		$("#hotelnearby").keyup(function(event) {
			var hotelnearby = $("#hotelnearby").val();
			if(hotelnearby) {
				if (event.keyCode != 13 && event.keyCode != 9 && event.keyCode != 20 && event.keyCode != 16 && event.keyCode != 17) {
					getnearby();
				}
			}
		});
		//绑定附近地标自动完成事件
		$("#hotelnearby").focus(function() {
			if($("#cityname").val() != '' && $("#hotelnearby").val() !='') {
				getnearby();
			}
		});
		$("#hotelnearby").blur(function() {
			if(get['cityname'] != '' && get['hotelnearby'] != '' && get['coordinate'] == '') {
				getnearby();
			}
		});
		//--------------------
		var options = {
			beforeSubmit: formverify,
			success:function(){
				return false;
			}
		}
		$('#docsearch').submit(function() {
			$(this).ajaxSubmit(options);
			return false;
		});
	});
	
	function formverify(formData, jqForm, options) {
		var queryString = $.param(formData);
		var get=urlarray(queryString);
		if(get['cityname']=="") {
			document.docsearch.cityname.focus();
			alert("城市不能为空，请你选择城市");
			return false;
		}
		if(get['cityname'] != "" && get['cityid'] == "") {
			setcityid(get['cityname']);
		}
		if(get['tm1']=="") {
			document.docsearch.tm1.focus();
			alert("入住日期不能为空");
			return false;
		}
		if(get['tm2']=="") {
			document.docsearch.tm2.focus();
			alert("离店日期不能为空");
			return false;
		}
		if(get['tm1'] != '' && get['tm2'] != '') {
			if(!checkdate(get['tm1']) || !checkdate(get['tm2'])) {
				if(!checkdate(get['tm1'])) {
					document.docsearch.tm1.focus();	
				} else if(!checkdate(get['tm2'])) {
					document.docsearch.tm2.focus();	
				}
				alert("日期格式错误，请重新选择");
				return false;
			}
			var d = gethasdate(get['tm1'],get['tm2']);
			if(d > 0) {
				document.docsearch.tm2.focus();
				alert("日期选择错误，入住日期不能大于离开日期！");
				return false;
			}
		}
		if(get['lowerprice'] !="" && get['heightprice'] != "") {
			if(isNaN(parseInt(get['lowerprice'])) || isNaN(parseInt(get['heightprice']))) {
				if(isNaN(parseInt(get['lowerprice']))) {
					document.docsearch.lowerprice.focus();
				} else if(isNaN(parseInt(get['heightprice']))) {
					document.docsearch.heightprice.focus();
				}
				alert("价格必须是数字，请返回重新填写");
				return false;
			}
		}
		if(get['hotelname']!=""){
			if(get['hotelname'].match(/[\'\"\<\>\,\;\^\$\(\)\!\.]+/ig)!=null) {
				document.docsearch.hotelname.focus();
				alert("酒店名称存在非法字符，请重新填写");
				return false;
			}
		}
		var esarchurl="index.php?archive=hotelmain&action=hotelsearch&lng=cn&mid=&cityname="+encodeURIComponent(get['cityname'])+"&cityid="+get['cityid']+"&checkindate="+get['tm1']+"&checkoutdate="+get['tm2']+"&lowerprice="+get['lowerprice']+"&heightprice="+get['heightprice']+"&hotelnearby="+encodeURIComponent(get['hotelnearby'])+"&coordinate="+get['coordinate']+"&hotelname="+encodeURIComponent(get['hotelname'])+"&hotelstar="+get['hotelstar']+"&ser="+get['ser']+"&MaxPerPage=20&page_id=1";
		//hotelsearch(esarchurl)
		//return false;
		location.href = esarchurl;
	}

	$(function() {
		gDate("tm1","tm2");_g('img_tm1').onclick=_g('tm1').onclick;
		gDate("tm2");_g('img_tm2').onclick=_g('tm2').onclick;
	});
</script>
<script type="text/javascript" src="/js/calendar.js"></script>
</head>

<body class="bodyflow">
<div class="centerrightwindow">
<div class="formdiv" id="searchmanger">
<form name="docsearch" id="docsearch" method="post" action="index.php?archive=ordermain&action=paysave">
	<input type="hidden" name="inputclass" value="add">
	<input type="hidden" name="tab" id="payplugaddtab" value="true">
	<div id="mainbodyauto" class="manageadd">
		<div class="maindobycontent">
			<!--查看已选择的类型-->
			<div class="suggestion">
				<span class="sugicon"><span class="strong colorgorning2">当前操作提示：</span><span class="colorgorningage">请在以下输入框中操作您要搜索的信息</span></span>
			</div>
			<div class="sugtitle">
				<span class="sugtitleicon"><span class="strong colorgorning2">基本搜索信息</span></span>
			</div>
			<div class="sugtitle-line"></div>
			<div class="formdiv">
				<table border="0" width="100%">
					<tr class="trstyle2">
						<td width="15%" class="trtitle01">选择城市</td>
						<td width="85%" class="trtitle02">
                         <input id="cityid" name="cityid" type="hidden" value="" />
						  <input id="cityname" name="cityname" size="20" class="infoInput" title="可以填写汉字、拼音、拼音缩写" /><span class="colorred strong"> *</span>
																
							<span class="cautiontitle">可以填写汉字、拼音、拼音缩写</span>
                            <div id="autoCompleteCityName" class="cityname"></div>
						</td>
					</tr>
                    <tr class="trstyle2">
                        <td width="15%" class="trtitle01">入住日期</td>
                        <td width="80%" class="trtitle02">
                            <input id="tm1" type="text" name="tm1" value="" class="infoInput" />
                            <img style="cursor:pointer;" src="/images/calendar.gif" id="img_tm1" width="16" height="19" align="absmiddle" />
                            　离店日期						<input id="tm2" type="text" name="tm2" value="" class="infoInput" />
                            <img style="cursor:pointer;" src="/images/calendar.gif" id="img_tm2" width="16" height="19" align="absmiddle" /><span class="colorred strong"> *</span>
                      </td>
				  </tr>
                	<tr class="trstyle2">
                    	<td width="15%" class="trtitle01">价格范围</td>
                        <td width="80%" class="trtitle02">
                        <input id="lowerprice" name="lowerprice" size="10" class="infoInput" title="可以填写酒店最低的价格范围 例如：1" /> 至 <input id="heightprice" name="heightprice" size="10" title="可以填写酒店的最高价格范围 例如：150" class="infoInput" />
                      </td>
				  </tr>
                    <tr class="trstyle2">
						<td width="15%" class="trtitle01">附近标志性地标</td>
						<td width="85%" class="trtitle02">
						  <input id="hotelnearby" name="hotelnearby" size="20" class="infoInput" style="width:200px;" title="您可以输入你去的那个地方附近的主要标志，例如：天安门、西客站、海龙大厦等等" />
							<input id="coordinate" name="coordinate" type="hidden" value="" />									
							<span class="cautiontitle">附近标志性地标 例如：天安门、西客站等</span>
                            <div id="autoCompleteNearby" class="hotelnearby"></div>
						</td>
					</tr>
                    
				</table>
			</div>
			<div class="sugtitle">
				<span class="sugtitleicon"><span class="strong colorgorning2">酒店基本属性</span></span>
			</div>
			<div class="sugtitle-line"></div>
			<div class="formdiv" id="orderattrlist">
				<table border="0" width="100%">
					<tr class="trstyle2">
						<td width="15%" class="trtitle01">酒店名称</td>
						<td width="85%" class="trtitle02">
							<input type="text" id="hotelname" name="hotelname" size="30" maxlength="80" value="" class="infoInput" title="可以输入如家、快捷、7天、锦江之星、前门店" />
							<span class="cautiontitle">可以输入如家、快捷、7天等酒店关键字</span>
						</td>
					</tr>
					<tr class="trstyle2">
						<td width="15%" class="trtitle01">酒店星级</td>
						<td width="85%" class="trtitle02">
							<select size="1" name="hotelstar" class="select" id="hotelstar">
							<option value="0">不限星级</option>
                            <option value="1">二星下/经济型</option> 
                            <option value="2">三星级/舒适型</option>
                            <option value="3">四星级/高档型</option>
                            <option value="4">五星级/豪华型</option> 
						</select>
							<span class="cautiontitle">选择酒店星级</span>
						</td>
					</tr>
                    <tr class="trstyle2">
                    	<td width="15%" class="trtitle01">设施服务</td>
                        <td width="85%" class="trtitle02"><input type="checkbox" name="ser" id="ser" value="adsl" />宽带
                        </td>
                    </tr>
                    <tr class="trstyle2">
                    	<td width="15%" class="trtitle01"></td>
                        <td width="85%" class="trtitle02">
                        </td>
                    </tr>
                    <tr class="trstyle2">
                    	<td width="15%" class="trtitle01"></td>
                        <td width="85%" class="trtitle02"><input type="submit" id="submitbotton" value="查询酒店" title="查询酒店" class="buttonface" />
                        </td>
                    </tr>
			  </table>
			</div>
		</div>
	</div>
</form>
</div>
</div>
</body>

</html>